cd "C:\Users\junya\Dropbox\Academic\Research\Varieties of Leadership\Replication files"
use data_individual, clear
************************************************
************** Main Result *********************
************************************************

************** Table 1 *********************

eststo m1: reg psc   collegial loglength connected age zb_tenure elite_college avg_gdpidx   avg_growrev   , robust  
estadd local yfe "$\checkmark$"
estadd local ctl "$\checkmark$"

eststo m2: reg psc   prob_type1 loglength connected age zb_tenure elite_college avg_gdpidx   avg_growrev   , robust  
estadd local yfe "$\checkmark$"
estadd local ctl "$\checkmark$"



eststo m3: reg purge2   collegial  loglength connected    psc  age zb_tenure elite_college  avg_gdpidx   avg_growrev   , robust  
estadd local yfe "$\checkmark$"
estadd local ctl "$\checkmark$"


eststo m4: reg purge2   prob_type1  loglength connected    psc  age zb_tenure elite_college  avg_gdpidx   avg_growrev   , robust  
estadd local yfe "$\checkmark$"
estadd local ctl "$\checkmark$"


esttab m1   m2    m3 m4 using out.txt, nonote nobaselevels keep(collegial prob_type1 connected ) order(collegial  prob_type1 loglength connected elite_college avg_gdpidx   avg_growrev) b(3) se(3) ///
star(* 0.1 ** 0.05 *** 0.01) label booktabs replace   ///
nomtitles mgroup("Promotion" "Demotion", pattern(1 0 1 0) prefix(\multicolumn{@span}{c}{) suffix(}) span erepeat(\cmidrule(lr){@span})) ///
stats(yfe ctl N, labels("Age and tenure" "Other controls" "Number of leaders") fmt(0 0) )


***************************************************
***************** Online Appendix *****************
***************************************************

************** Table A.6 *********************


eststo m1: reg psc  i.commentyear collegial loglength connected age zb_tenure elite_college avg_gdpidx   avg_growrev   , robust  
estadd local yfe "$\checkmark$"
estadd local ctl "$\checkmark$"

eststo m2: reg psc  i.commentyear prob_type1 loglength connected age zb_tenure elite_college avg_gdpidx   avg_growrev   , robust  
estadd local yfe "$\checkmark$"
estadd local ctl "$\checkmark$"



eststo m3: reg purge2 i.commentyear  collegial  loglength connected    psc  age zb_tenure elite_college  avg_gdpidx   avg_growrev   , robust  
estadd local yfe "$\checkmark$"
estadd local ctl "$\checkmark$"


eststo m4: reg purge2 i.commentyear  prob_type1  loglength connected    psc  age zb_tenure elite_college  avg_gdpidx   avg_growrev   , robust  
estadd local yfe "$\checkmark$"
estadd local ctl "$\checkmark$"


esttab m1   m2    m3 m4 using out.txt, nonote nobaselevels keep(collegial prob_type1 connected ) order(collegial  prob_type1 loglength connected elite_college avg_gdpidx   avg_growrev) b(3) se(3) ///
star(* 0.1 ** 0.05 *** 0.01) label booktabs replace   ///
nomtitles mgroup("Promotion" "Demotion", pattern(1 0 1 0) prefix(\multicolumn{@span}{c}{) suffix(}) span erepeat(\cmidrule(lr){@span})) ///
stats(yfe ctl N, labels("Year of evaluation FE" "Controls" "Number of leaders") fmt(0 0 0) )


************** Table A.7: Focus on 2008--2012  *********************

reg psc   collegial if inrange(year, 2008, 2012) 

reg purge2   collegial  if inrange(year, 2008, 2012) 


************* Table A.8: Re-weight by proportions in the 2008--2012 period *******************


g wt=1
replace wt=0.5417/0.6047 if collegial==0 & y812==0
replace wt=0.4583/0.3953 if collegial==1 & y812==0


eststo m1: reg psc   collegial  loglength connected       age zb_tenure elite_college  avg_gdpidx   avg_growrev [aw=wt]  , robust  
estadd local ctl "$\checkmark$"

eststo m2: reg purge2   collegial  loglength connected    psc  age zb_tenure elite_college  avg_gdpidx   avg_growrev [aw=wt]  , robust  
estadd local ctl "$\checkmark$"


esttab m1  m2  using out.txt, nonote nobaselevels keep(collegial connected) order(collegial ) b(3) se(3) ///
star(* 0.1 ** 0.05 *** 0.01) label booktabs replace   ///
nomtitles mgroup("Promotion" "Demotion", pattern(1 1) prefix(\multicolumn{@span}{c}{) suffix(}) span erepeat(\cmidrule(lr){@span})) ///
stats(ctl N, labels("Controls" "Number of leaders") fmt(0 0  ) )




****************** Table A.9: Incorporate missing in estimation ******************
g type_wm=collegial
replace type_wm=2 if collegial==.
g zb_year2=year-psec_firstzb


fvset base 2 type_wm
label def ms 0 "Autocratic style" 1 "Collegial style" 2 "Missing remarks"
label val  type_wm  ms

eststo clear
eststo m1: reg psc   i.type_wm   connected  psec_age  zb_year2 elite_college avg_gdpidx   avg_growrev   , robust  
lincom 1.type_wm-0.type_wm
estadd scalar v=`r(estimate)'
estadd local yfe "$\checkmark$"
estadd local ctl "$\checkmark$"


eststo m2: reg anypurge   i.type_wm  psc pb  connected  psec_age zb_year2 elite_college avg_gdpidx   avg_growrev   , robust  
test 1.type_wm=0.type_wm
lincom 1.type_wm-0.type_wm
estadd scalar v=`r(estimate)'
estadd local yfe "$\checkmark$"
estadd local ctl "$\checkmark$"

esttab m1   m2    using out.txt, nonote nobaselevels keep(*type_wm   connected ) order(*type_wm connected) b(3) se(3) ///
refcat(0.type_wm "Reference group: evaluation missing", nolabel) star(* 0.1 ** 0.05 *** 0.01) label booktabs replace   ///
nomtitles mgroup("Promotion" "Demotion", pattern(1 1 ) prefix(\multicolumn{@span}{c}{) suffix(}) span erepeat(\cmidrule(lr){@span})) ///
stats(v ctl N, labels("Collegial - autocratic" "Other controls" "Number of leaders") fmt(2 0 0) )


*****************************	Table A.10: Use Posterior Probability as Independent Variable *************************
eststo clear
eststo m1: reg psc   prob_type1  age zb_tenure   , robust 
estadd local yfe "$\checkmark$"
 
eststo m2: reg psc   prob_type1 loglength connected age zb_tenure elite_college avg_gdpidx   avg_growrev   , robust  
estadd local yfe "$\checkmark$"

eststo m3: reg purge2    prob_type1  psc   age zb_tenure   , robust  
estadd local yfe "$\checkmark$"

eststo m4: reg purge2   prob_type1  loglength connected    psc  age zb_tenure elite_college  avg_gdpidx   avg_growrev   , robust  
estadd local yfe "$\checkmark$"

esttab m1 m2 m3 m4   using out.txt, nonote nobaselevels keep(prob_type1  loglength connected elite_college avg_gdpidx   avg_growrev ) order(prob_type1  loglength connected elite_college avg_gdpidx   avg_growrev) b(3) se(3) ///
star(* 0.1 ** 0.05 *** 0.01) label booktabs replace   ///
nomtitles mgroup("Promotion to PSC" "Purge/Demotion", pattern(1 0 1 0) prefix(\multicolumn{@span}{c}{) suffix(}) span erepeat(\cmidrule(lr){@span})) ///
stats(yfe r2_a  N, labels("Age and tenure" "Adjusted R$^2$" "Number of leaders") fmt(0 2 0) )


************* Table A.11: Remove Immediately to PSC **************
eststo clear
eststo m1: reg psc   collegial loglength connected age zb_tenure elite_college avg_gdpidx   avg_growrev  if yr_to_psc>5 , robust  
estadd local yfe "$\checkmark$"
estadd local ctl "$\checkmark$"

eststo m2: reg psc   prob_type1 loglength connected age zb_tenure elite_college avg_gdpidx   avg_growrev  if yr_to_psc>5 , robust  
estadd local yfe "$\checkmark$"
estadd local ctl "$\checkmark$"

esttab m1   m2    using out.txt, nonote nobaselevels keep(collegial prob_type1   ) order(collegial  prob_type1) b(3) se(3) ///
star(* 0.1 ** 0.05 *** 0.01) label booktabs replace   ///
nomtitles mgroup("Promotion" "Demotion", pattern(1   1 ) prefix(\multicolumn{@span}{c}{) suffix(}) span erepeat(\cmidrule(lr){@span})) ///
stats(ctl N, labels("Controls" "Number of leaders") fmt(0 0) )



****************** Table A.12: Strategy vs. Personality ******************


eststo clear
eststo m1: reg psc   avgtype_d  dev_collegial loglength connected age zb_tenure elite_college avg_gdpidx   avg_growrev   , robust  
estadd local yfe "$\checkmark$"
estadd local ctl "$\checkmark$"

eststo m2: reg psc   avgtype_c  dev_prob loglength connected age zb_tenure elite_college avg_gdpidx   avg_growrev   , robust  
estadd local yfe "$\checkmark$"
estadd local ctl "$\checkmark$"



eststo m3: reg purge2   avgtype_d  dev_collegial  loglength connected    psc  age zb_tenure elite_college  avg_gdpidx   avg_growrev   , robust  
estadd local yfe "$\checkmark$"
estadd local ctl "$\checkmark$"


eststo m4: reg purge2   avgtype_c  dev_prob  loglength connected    psc  age zb_tenure elite_college  avg_gdpidx   avg_growrev   , robust  
estadd local yfe "$\checkmark$"
estadd local ctl "$\checkmark$"


esttab m1   m2    m3 m4 using out.txt, nonote nobaselevels keep(avgtype_d avgtype_c dev_collegial  dev_prob* )   b(3) se(3) ///
order(avgtype_d dev_collegial avgtype_c   dev_prob*) star(* 0.1 ** 0.05 *** 0.01) label booktabs replace   ///
nomtitles mgroup("Promotion" "Demotion", pattern(1 0 1 0) prefix(\multicolumn{@span}{c}{) suffix(}) span erepeat(\cmidrule(lr){@span})) ///
stats(yfe N, labels("Controls" "Number of leaders") fmt(0 0) )



*************** Table A.13: Individual Fixed Effects *************


eststo m1: reg psc   lfe loglength connected age zb_tenure elite_college avg_gdpidx   avg_growrev    , robust 
estadd local yfe "$\checkmark$"
estadd local ctl "$\checkmark$"


eststo m2: reg purge2   lfe loglength connected age zb_tenure elite_college avg_gdpidx   avg_growrev    , robust 
estadd local yfe "$\checkmark$"
estadd local ctl "$\checkmark$"



esttab m1   m2    using out.txt, nonote nobaselevels keep(lfe )  b(3) se(3) ///
star(* 0.1 ** 0.05 *** 0.01) label booktabs replace   ///
nomtitles mgroup("Promotion" "Demotion", pattern(1  1 ) prefix(\multicolumn{@span}{c}{) suffix(}) span erepeat(\cmidrule(lr){@span})) ///
stats(yfe ctl N, labels("Age and tenure" "Other controls" "Number of leaders") fmt(0 0) )





****************** Table A.14: Controlling for region fixed effects ******************

eststo m1: reg psc   collegial loglength connected age zb_tenure elite_college avg_gdpidx   avg_growrev muni south coast minor i.year  , robust  
estadd local yfe "$\checkmark$"
estadd local ctl "$\checkmark$"

eststo m2: reg purge2   collegial  loglength connected    psc  age zb_tenure elite_college  avg_gdpidx   avg_growrev  muni south coast minor   i.year , robust  
estadd local yfe "$\checkmark$"
estadd local ctl "$\checkmark$"

esttab m1  m2  using out.txt, nonote nobaselevels keep(collegial muni south coast minor  ) order(collegial  prob_type1 loglength connected elite_college avg_gdpidx   avg_growrev) b(3) se(3) ///
star(* 0.1 ** 0.05 *** 0.01) label booktabs replace   ///
nomtitles mgroup("Promotion" "Demotion", pattern(1 1) prefix(\multicolumn{@span}{c}{) suffix(}) span erepeat(\cmidrule(lr){@span})) ///
stats(yfe ctl N, labels("Year fixed effects" "Other controls" "Number of leaders") fmt(0 0 0) )


****************** Table A.15: Coming vs. Going ******************
eststo clear

eststo m1: reg psc   collegial loglength connected age zb_tenure elite_college avg_gdpidx   avg_growrev comer    , robust  
estadd local ctl "$\checkmark$"

eststo m2: reg purge2   collegial  loglength connected    psc  age zb_tenure elite_college  avg_gdpidx   avg_growrev comer   , robust  
estadd local ctl "$\checkmark$"

esttab m1  m2  using out.txt, nonote nobaselevels keep(collegial comer ) order(collegial  comer) b(3) se(3) ///
star(* 0.1 ** 0.05 *** 0.01) label booktabs replace   ///
nomtitles mgroup("Promotion" "Demotion", pattern(1 1) prefix(\multicolumn{@span}{c}{) suffix(}) span erepeat(\cmidrule(lr){@span})) ///
stats(ctl N, labels("Controls" "Number of leaders") fmt(0 0  ) )





************************** Table A.16: Probit Models ******************************
eststo clear
eststo m1: probit psc   collegial  age zb_tenure   , robust 
estadd local yfe "$\checkmark$"
 
eststo m2: probit psc   collegial loglength connected age zb_tenure elite_college avg_gdpidx   avg_growrev   , robust  
estadd local yfe "$\checkmark$"

eststo m3: probit purge2    collegial  psc   age zb_tenure   , robust  
estadd local yfe "$\checkmark$"

eststo m4: probit purge2   collegial  loglength connected     psc age zb_tenure elite_college  avg_gdpidx   avg_growrev   , robust  
estadd local yfe "$\checkmark$"

esttab m1 m2 m3 m4   using out.txt, nonote nobaselevels keep(collegial  loglength connected elite_college avg_gdpidx   avg_growrev ) order(collegial  loglength connected elite_college avg_gdpidx   avg_growrev) b(3) se(3) ///
star(* 0.1 ** 0.05 *** 0.01) label booktabs replace   ///
nomtitles mgroup("Promotion to PSC" "Purge/Demotion", pattern(1 0 1 0) prefix(\multicolumn{@span}{c}{) suffix(}) span erepeat(\cmidrule(lr){@span})) ///
stats(yfe r2_a  N, labels("Age and tenure" "Adjusted R$^2$" "Number of leaders") fmt(0 2 0) )




****************** Table A.17: Categorical Outcomes ******************
/// Differentiating between pb and psc ///
g promote_order=pb==1|psc==1
replace promote_order=2 if psc==1


eststo m1: oprobit promote_order  collegial loglength connected age zb_tenure elite_college avg_gdpidx   avg_growrev   , robust  

forv i=1/2{
margins, dydx(collegial) predict(out(`i')) post
eststo mx`i'
estadd local ctl "$\checkmark$"
estadd local yfe "$\checkmark$"
est restore m1
}

esttab    mx1 mx2   using out.txt, nonote nobaselevels keep(collegial) b(3) se(3) ///
star(* 0.1 ** 0.05 *** 0.01) label booktabs replace   ///
mtitles("Promoted to PB" "Promoted to PSC") mgroup("Promotion (ordered)", pattern(1 0 ) prefix(\multicolumn{@span}{c}{) suffix(}) span erepeat(\cmidrule(lr){@span})) ///
stats(yfe ctl N, labels("Age and tenure" "Other controls" "Number of leaders") fmt(0 0) )


****************** Table A.18: Multinomial Outcomes ******************
g pro_rank=0
replace pro_rank=1 if  psc==1
replace pro_rank=2 if purge2==1

eststo clear
eststo m: mlogit pro_rank   collegial loglength connected age zb_tenure elite_college avg_gdpidx   avg_growrev  , robust  

forv i=1/2{
margins, dydx(collegial) pr(out(`i')) post atmeans
eststo mx`i'
estadd local ctl "$\checkmark$"
estadd local yfe "$\checkmark$"

est restore m
}

esttab   mx1 mx2   using out.txt, nonote nobaselevels keep(collegial)  b(3) se(3) ///
star(* 0.1 ** 0.05 *** 0.01) label booktabs replace   ///
mtitles("Promotion to PSC" "Demotion") mgroup("Career Outcomes (Multinomial)", pattern(1 0) prefix(\multicolumn{@span}{c}{) suffix(}) span erepeat(\cmidrule(lr){@span})) ///
stats(ctl N, labels("Controls" "Number of leaders") fmt(0 0) )







